Skip to content

Conversation

bavshin-f5
Copy link
Member

ngx_merge_path_value takes care of that when it reallocates a resolved relative path, but the reallocation is skipped if we pass an absolute path with NGX_ACME_STATE_PREFIX.

As a result, we get a lovely

drwx------ 2 root  root 4096 Oct  6 21:38  acme_dogtag
drwx------ 2 nginx root 4096 Oct  6 21:38 'acme_dogtag'$'\034'
drwx------ 2 root  root 4096 Oct  6 21:38  acme_stepca
drwx------ 2 nginx root 4096 Oct  6 21:38  acme_stepcaU
drwx------ 2 nginx root 4096 Oct  6 21:38  acme_vault

Note for future: we need to enforce such requirements in a type system, e.g. by requiring CStr for path operations in ngx-rust.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a critical bug in the default state path generation where paths were not being NUL-terminated when using absolute paths with NGX_ACME_STATE_PREFIX. This caused filesystem corruption with garbled directory names containing unprintable characters.

Key changes:

  • Increased memory reservation to account for NUL terminator
  • Added explicit NUL byte to path buffer
  • Adjusted returned length to exclude NUL terminator from string length

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@xeioex xeioex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix ngx_merge_path_value to ngx_conf_merge_path_value in Conf: ensure that the default path is NUL-terminated. commit log.

Copy link
Contributor

@xeioex xeioex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise looks good.

`ngx_conf_merge_path_value` takes care of that when it reallocates a
resolved relative path, but the reallocation is skipped if we pass an
absolute path with `NGX_ACME_STATE_PREFIX`.
@bavshin-f5 bavshin-f5 force-pushed the nul-terminated-paths branch from 18c4d07 to 2b84d85 Compare October 7, 2025 00:20
@bavshin-f5 bavshin-f5 requested a review from xeioex October 7, 2025 00:29
@bavshin-f5 bavshin-f5 merged commit f98716f into nginx:main Oct 7, 2025
15 checks passed
@bavshin-f5 bavshin-f5 deleted the nul-terminated-paths branch October 7, 2025 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants